<?php $this->load->view(TEMPLATE_NAME.'/admin/header');?>
<?php $this->load->view(TEMPLATE_NAME.'/admin/side_left');?>
<script type="text/javascript" src="<?php echo base_url()?>js/jquery-1.4.2.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>js/jquery.validate.pack.js"></script>
<script>
$(document).ready(function(){    
    $.validator.addMethod("smsCheck", function(val, elem) {
        var sms_alert = $("input[name='sms_alert']:checked").val();                                                
            if((sms_alert == '1') && ($('#phone_number').val() == '')) {            
                return false;    
            }else{
                return true;
            }
        },        
        "Insert phone number"
    );
    
    $.validator.addMethod("emailCheck", function(val, elem) {
        var email_alert = $("input[name='email_alert']:checked").val();                                                
            if((email_alert == "1") && ($('#email_address').val() == "")){          
                return false;    
            }else{
                return true;
            }
        },        
        "Insert email Address"
    );
    
    $('#settings_form').validate({
        rules : {
            email_option : "required",
            advertising : "required",
            email_alert : {
                required : true,
                emailCheck: true    
            },
            sms_alert : {
                required : true,
                smsCheck : true    
            }            
        }
        /*
	    messages:{
            email_option : "Please select the email option",
            advertising : "Please select the advertising",
            email_alert : "Please select the email alert option",
            sms_alert : "Please select the sms alert option",            
        } 
        */   
    });    
    
});
</script>
<div class="page noright adminpage adminuser">
    
        <?php $this->load->view(TEMPLATE_NAME.'/admin/profile/profile_tabs');?>
    <h2 class="no">General Settings</h2>   
    <p class="black f13"><strong>General settings and preferences for your profile. </strong><br />
    Here you can set the way you would like to interact with and control Turn it Around. <br />
    As new features are added to the website, more options will be added here.</p>
    <?php if(!empty($notification)): ?>
    <p><?php echo $notification ?></p>
    <?php endif; ?>
    <hr />
    
    <?php echo form_open('admin/profile/settings',array('method' => 'post', 'class' => 'formstep formp', 'id' => 'settings_form'));?>
    <p class="nop">CRIME REPORTS - Actual reports of crimes that have happened near you </p>
    <hr />
<?php
$crime_report_checkbox_status = ($settings['receive_crime_report'] == 'yes')?TRUE:FALSE;
$crime_report_checkbox = array(
    'name'        => 'receive_crime_report',
    'id'          => 'receive_crime_report',
    'value'       => 'yes',
    'checked'     => $crime_report_checkbox_status,
    );
?>
    <p><?php echo form_checkbox($crime_report_checkbox); ?> <strong>Send me actual Crime Reports based on my location - <span class="purple norm"> <a href="<?php echo site_url('admin/profile/location'); ?>">(go to location settings)</a></span></strong></p>
    <hr />
    <p class="nop">CRIME ALERTS! - Send me Crime Alerts and Information from these Network/s : <span class="purple norm"> (select)</span></p>
    <hr />    
    <?php if(!empty($network_data)): // if network list is not empty ?>
    <?php foreach($network_data as $key=>$value): ?>
    <p><input type="checkbox" name="net_val[<?php echo $value['id_network']; ?>][]" <?php if($value['received_email'] == "1"){?>checked="checked"<?php }?> value="1"/> <strong><?php echo $value['name']; ?></strong></p>
    
    <?php endforeach; ?>
    <?php endif; // endif network list is not empty?>
    <p class="nop">Alert Settings:  <span class="purple norm"> (As crimes or newsflashes are reported - how would you like to be notified?)</span></p>
    <p><label class="sh">By E-mail:</label> 
    <input type="radio" name="email_alert" <?php if ($settings['email_alert'] == "0"){?>checked="checked"<?php }?> value="0"/> No thanks 
    <input type="radio" name="email_alert" <?php if ($settings['email_alert'] == "1"){?>checked="checked"<?php }?> value="1"/> Yes, send to: 
    <?php    
    echo form_input(array('name' => 'email_address', 'id' => 'email_address'),$settings['email_address']); ?>
    <label id="email_error"></label> 
    </p>
    
    <?php echo form_error('email_alert') ?>
    <?php echo form_error('email_address') ?>
    <p><label class="sh">Via SMS:</label> 
    <input type="radio" name="sms_alert" <?php if ($settings['sms_alert'] == "0"){?>checked="checked"<?php }?> value="0"/> No thanks 
    <input type="radio" name="sms_alert" <?php if ($settings['sms_alert'] == "1"){?>checked="checked"<?php }?> value="1"/> Yes, send to: 
    <?php echo form_input(array('name'=>'phone_number','id' =>'phone_number'),$settings['phone_number']); ?>
    <label id="sms_error"></label>
    </p>
    
    <?php echo form_error('sms_alert') ?>
    <?php echo form_error('phone_number') ?>
    <hr />
    <p class="nop whr">RECEIVE E-MAIL FROM OTHER USERS :   <span class="purple norm"> (Select Option)</span></p>
    <hr />
    You can choose who you allow to contact you through the website. This is through a secure and <br />anonoymous form system and no-one can directly see your details. 
    <hr />
    <p><input type="radio" name="email_option" <?php if ($settings['contact_preferences'] == "all"){?>checked="checked"<?php }?> value="all"/> 
    <strong>Allow any member of Turn It Around to contact me via the secure e-mail system</strong></p>
    <p><input type="radio" name="email_option" <?php if ($settings['contact_preferences'] == "member"){?>checked="checked"<?php }?> value="member"/> 
    <strong>Only allow members in networks that I am a member of to contact me. </strong></p>
    <p><input type="radio" name="email_option" <?php if ($settings['contact_preferences'] == "none"){?>checked="checked"<?php }?> value="none"/> 
    <strong>Do not allow other members to contact me at all </strong></p>
    <hr />
    <p class="nop whr">ADVERTISING OPT-IN :   <span class="purple norm">(Select Yes or No)</span></p>
    <hr />
    Would you be happy to receive occassional advertisng on product specials and advertising from companies near you? <strong>You can change this option at any time.</strong>
    <hr />
    <p><input type="radio" name="advertising" <?php if ($settings['advertising'] == "1"){?>checked="checked"<?php }?> value="1"/> 
    <strong>Yes, I am happy to receive marketing specials</strong></p>
    <p><input type="radio" name="advertising" <?php if ($settings['advertising'] == "0"){?>checked="checked"<?php }?> value="0"/> 
    <strong>No, thanks </strong></p>
    <?php echo form_error('advertising') ?>
    <hr />
    
    <?php 
        $form_button = array(
            'type'=>'submit',
            'name'=>'submit',
            'value'=>'submit',
            'content'=>'Submit',
        );
        echo form_button($form_button) ?>
    <div class="clear"></div>
    </form><!-- formstep -->
</div><!-- page -->
<?php $this->load->view(TEMPLATE_NAME.'/admin/footer');?>
